<?php
class Application_Model_adminuser extends Application_Model_DomainObject{
	
        protected $_id;//
        protected $_loginname;//登录名称
        protected $_nikename;//真实姓名
        protected $_password;//密码
        protected $_roleid;//角色序号
        protected $_lastlogin;//最后登录时间
        protected $_lastip;//最后登录ip
        protected $_loginnum;//登录次数


        public static function byloginname($username)
        {
            $where[' loginname = '] = $username;
            $result = Application_Model_adminuser::getDao()->queryOne($where);
            return $result;
        }
        
        public static function getFilter($name,$pagesize,$pageindex)
        {
            $where = array();
            if($name != null){
                $where[" loginname like "] = "%".$name."%";
                $where[" or nikename like "] = "%".$name."%";
            }
            return Application_Model_adminuser::getDao()->queryPage($where,'id desc',$pagesize,$pageindex);
        }
        
        public function getrolename()
        {
            if($this->_roleid){
                switch ($this->_roleid) {
                    case 1:
                        return "超级管理员";
                        break;
                    case 2:
                        return "管理员";
                        break;
                    case 3:
                        return "客服";
                        break;
                    case 100:
                        return "代理客户";
                        break;
                    default:
                        return "";
                        break;
                }
            }
        }
}